<?php 
/**
* 前台首页控制器
*/
class IndexController  extends Controller
{
	public function index()
	{
		// echo "可以访问到这个位置";exit;
		$msgs = M('msg')->select();
		// $name = "学并思XXXXX";
		// $age = 19;

		// $db = array('db'=>'db');

		// // echo "留言板首页";
		// // 分配变量
		// $this->assign('name',$name);
		// $this->assign('age',$age);
		$this->assign('db',$msgs);
		$this->display('test');

		// include VIEW_PATH.'/'.CONTROLLER_NAME.'/'.ACTION_NAME.'.html';
	}

	public function show()
	{

		$data = M('stu')->select();

		$this->assign('data',$data);

		$data = D('Msg')->rand();

		var_dump($data);

		// include VIEW_PATH.'/Index/show.html';
		// include VIEW_PATH.'/'.CONTROLLER_NAME.'/'.ACTION_NAME.'.html';
		$this->display();
	}
	//增加留言的方法
	public function add()
	{
		$data = $_POST;
		$data['create_time']=time();

		$res = M('msg')->add($data);

		if($res){
			header("Location:./index.php");
		}
	}
	public function del()
	{
		$id = $_GET['id'];
		M('msg')->where('id='.$id)->del();
	}
}

















 ?>